const window_sys_cache_key:any = 'system_cache_obj';
/**
 * 系统帮助工具类 lmy 2024-05-17
 */
export const SystemHandleObject = {
  getWindowCacheObj: function () {
    if (!window[window_sys_cache_key]) {
      window[window_sys_cache_key] = {} as any;
    }
    return window[window_sys_cache_key];

  },
  setToWindowCache: function (key:any, value:any) {
    SystemHandleObject.getWindowCacheObj()[key] = value;
  },
  getFromWindowCache: function (key:any) {
    return SystemHandleObject.getWindowCacheObj()[key];
  },
  setOuterPath: function (path:any) {
    SystemHandleObject.setToWindowCache('outerPath', path);
  },
  getOuterPath : function () {
    return SystemHandleObject.getFromWindowCache('outerPath');
  },
  isInnerSystem: function () {
    let outerPath = SystemHandleObject.getOuterPath();
    if (outerPath) {
      return true;
    }
    return false;
  },
  addInnerSysClassToBody: function () {
    if (SystemHandleObject.isInnerSystem()) {
      window.document.body.classList.add('jz_in_sys_body');
    }

  },
  getPretendCookieObj:function (){
    let pretendCookieObj_str = localStorage.getItem('pretendCookieObj');
    if(!pretendCookieObj_str){
      pretendCookieObj_str = JSON.stringify({});
    }
    return JSON.parse(pretendCookieObj_str);
  },
  setToPretendCookie:function (key:any,value:any){
    let pretendCookieObj = SystemHandleObject.getPretendCookieObj();
    pretendCookieObj[key] = value;
    localStorage.setItem('pretendCookieObj',JSON.stringify(pretendCookieObj));
  },
  getFromPretendCookie:function (key:any){
    let pretendCookieObj = SystemHandleObject.getPretendCookieObj();
    return pretendCookieObj[key];
  },
  removeFromPretendCookie:function (key:any){
    let pretendCookieObj = SystemHandleObject.getPretendCookieObj();
    delete pretendCookieObj[key];
  },

}

